#pragma once
#include<iostream>

using namespace std;

class Date
{
	friend ostream& operator<<(ostream& out, Date& d);
	friend istream& operator>>(istream& in, Date& d);
	Date(int year = 1, int month = 1, int day = 1);
	bool checkDate() const;
	void Printf() const;
	int getmonthday(int year, int month) const
	{
		static int Day[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
		if (month == 2 && (year / 4 == 0 && year / 100 != 0) || (year / 400 == 0))
		{
			return 29;
		}
		return Day[month];
	}

	bool operator>(Date& d) const;
	bool operator<(Date& d) const;
	bool operator==(Date& d) const;
	bool operator>=(Date& d) const;
	bool operator<=(Date& d) const;
	bool operator!=(Date& d) const;

	Date& operator+=(int day);
	Date operator+(int day);
	Date& operator-=(int day);
	Date operator-(int day);
	int operator-(Date& d);
	Date& operator++();
	Date operator++(int);
	Date& operator--();
	Date operator--(int);
private:
	int _year;
	int _month;
	int _day;
};

ostream& operator<<(ostream& out, Date& d);
istream& operator>>(istream& in, Date& d);

